package com.springcloud.demo.service;

import com.springcloud.demo.pojo.Product;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ProductServiceFallbackFactory implements FallbackFactory<ProductService> {


    @Override
    public ProductService create(Throwable throwable) {
        return new ProductService() {
            @Override
            public Product selectProductById(Integer id) {
                log.error("service-provider 服务的 selectProductById 方法出现异常，异常信息如下："
                        + throwable);
                return new Product(id, "托底数据-openFeign", 1, 2666D);
            }
        };
    }
}
